
import {
    CFill,
    CStroke,
    CVector,
    CFeature,
    CVectorLayer,
    CStyle,
    CPolygon,
    CKML
} from '../ol'




export const Line = (linList, style = {}) => {
    const { color, width, fill } = style;
    let sds = new CVector()
    let sd = new CFeature({
        geometry: new CPolygon([linList]),
        type: 'PIPELINE_FACILITIES',
    });
    sd.setStyle(new CStyle({
        stroke: new CStroke({       // 线样式
            color: color ? color : '#007bff75',
            width: width ? width : 2
        }),
        fill: new CFill({           // 填充样式
            color: fill ? fill : "#11131700"
        })

    }));
    sds.addFeature(sd)
    return new CVectorLayer({
        zIndex: 0,
        source: sds
    })
}

export const Kml = (kmlurl) => {
    let sds = new CVector({
        url: kmlurl,
        format: new CKML({
            extractStyles: false
        })
    })
    return new CVectorLayer({
        zIndex: 0,
        source: sds
    })
}
